package com.moyq5.spring.boot.app.register.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import com.moyq5.spring.boot.app.register.AppInfo;
import com.moyq5.spring.boot.app.register.client.AppInfoSenderGateway.Gateway;
import com.moyq5.spring.boot.app.register.utils.JSON;

/**
 * @author Moyq5
 * @date 2019年3月6日
 */
@Component
public class AppInfoSenderDefault implements AppInfoSender {
	
	@Autowired
	private Gateway gateway;
	
	@Override
	public void send(AppInfo info) {
		String json = JSON.toString(info);
		MessageBuilder<String> builder = MessageBuilder.withPayload(json);
		gateway.send(builder.build());
	}

}
